#include <stdio.h>

int money = 1000;

void show()
{
    printf("\t\t\t\t\tATM取款机\t\t\t\t\t\n");
    printf("1.查询余额\n");
    printf("2.存款\n");
    printf("3.取款\n");
    printf("4.退出\n");
    printf("请选择操作(1-4):\n");
}

void check()
{
    printf("您的余额为:%d\n",money);
    return ;
}
void withdrawal()
{
    int num=0;
    printf("请输入您要取出的数额:");
    scanf("%d",&num);
    if(num>0&&num<=money)
    {
        money-=num;
        printf("存款成功,您的余额为:%d\n",money);
    }
    else if(num>money)
    {
        printf("您的余额不足\n");
    }
    else 
    {
        printf("数额错误,请重新输入\n");
    }
    return ;
}
void deposit()
{
    int num=0;
    printf("请输入您要存入的数额:\n");
    scanf("%d",&num);
    if(num>0)
    {
        money+=num;
        printf("您的余额为:%d\n",money);
    }
    else
    {
        printf("数额错误,请重新输入\n");
    }
}
int main(int argc, char const *argv[])
{
    int option = 0;
    show();
    while (1)
    {
        scanf("%d", &option);
        switch (option)
        {
        case 1:
            check();
            break;
        case 2:
            deposit();
            break;
        case 3:
            withdrawal();
            break;
        case 4:
        {
            printf("退出成功\n");
            return 0;
        }
        default:
            printf("输入错误,请输入数字(1-4):\n");
            break;
        }
    }

    return 0;
}
